#include"BlockQueue.hpp"
#include"Task.hpp"
#include<pthread.h>
#include<unistd.h>
#include<ctime>

int Add(int x,int y){
    return x+y;
}

void* consumer(void* args)
{
    BlockQueue<Task>* bq=(BlockQueue<Task>*)args;
    while(true)
    {
        Task task;
        bq->pop(&task);
        std::cout<<pthread_self()<<"consumer:"<<task._x<<"+"
        <<task._y<<"="<<task()<<std::endl;
    }
}
int main()
{
    srand((uint64_t)time(nullptr)^getpid()^0x3247);
    BlockQueue<Task>* bqueue=new BlockQueue<Task>();

    pthread_t c[2],p[2];
   for(int i=0;i<2;i++){
    pthread_create(c+i,nullptr,consumer,bqueue);
   }
    return 0;
}